<?php
require_once($_SERVER['DOCUMENT_ROOT']."/defaultconf.mex");
require_once($GLOBALS['PAD']."Modules/FTK9D4D0/modconf.mex");
MYTCONN(); 
	$qr_Country = '';
	$qr_Prov = '';
	
	if (!isset($_POST['OFCorr'])) {
		$_POST['OFCorr'] = 0;
	}
	if (!isset($_POST['OFIDCiudad'])) {
		$_POST['OFIDCiudad'] = 0;
	}
	if (!isset($_POST['OFCountry'])) {
		$_POST['OFCountry'] = 0;
	}
	if (!isset($_POST['OFProv'])) {
		$_POST['OFProv'] = 0;
	}
	if ($_POST['OFCountry'] > 0) {
		$qr_Prov = ' WHERE Prov_Pais = '.$_POST['OFCountry'];
	}
	if ($_POST['OFCorr'] > 0) {
		$qr_Country = ' INNER JOIN hd_detalletarifas ON dtr_Pais = pai_CodElite
		 WHERE dtr_Corresponsal = '.$_POST['OFCorr'].' 
		 GROUP BY pai_CodElite';
	}
?>
    <table width="100%"  border="0" cellpadding="0" cellspacing="5" bgcolor="#BCD1DC">
          <tr>
            <td><?php
			$qr_Corresponsal = "SELECT CorrNumero AS ID, CorrNombre AS NAME FROM Corresponsales";
			mn_field('select','ED','OFCorr',$_POST['OFCorr'],$qr_Corresponsal,'','','" onChange="
				document.QueryCorrAgencies.action=\''.$MODURL.'Lib/a04_COAG_ft.php\';
				subform(\'QueryCorrAgencies\',\'COAG_Filters\');');
            ?></td>
            <td><?php
			$qr_Country = "SELECT pai_CodElite AS ID, pai_NombreESP AS NAME FROM hd_paises {$qr_Country}";
			mn_field('select','ED','OFCountry',$_POST['OFCountry'],$qr_Country,' - Pais - ','','" onChange="
				document.QueryCorrAgencies.action=\''.$MODURL.'Lib/a04_COAG_ft.php\';
				subform(\'QueryCorrAgencies\',\'COAG_Filters\');');
            ?></td>
            <td><?php
			$qr_Prov = "SELECT Prov_ID AS ID, Prov_Provincia AS NAME FROM cp_provincias {$qr_Prov}";
			mn_field('select','ED','OFProv',$_POST['OFProv'],$qr_Prov,' - Regiao - ','','" onChange="
				document.QueryCorrAgencies.action=\''.$MODURL.'Lib/a04_COAG_ft.php\';
				subform(\'QueryCorrAgencies\',\'COAG_Filters\');');
            ?></td>
            <td><?php
			$qr_OFIDCiudad = "SELECT CiuNumero AS ID, CiuCiudad AS NAME FROM ciudades
							INNER JOIN oficcorresp ON CiuNumero = OFIDCiudad
							WHERE OFCorr = {$_POST['OFCorr']} AND CiuPais = {$_POST['OFCountry']}
							GROUP BY OFIDCiudad";
			mn_field('select','ED','OFIDCiudad',$_POST['OFIDCiudad'],$qr_OFIDCiudad,' - Cidade - ','','" onChange="
				document.QueryCorrAgencies.action=\''.$MODURL.'Lib/a04_COAG_ft.php\';
				subform(\'QueryCorrAgencies\',\'COAG_Filters\');');
            ?></td>
            <td><?php mn_field('button','ED','Quer','Consultar','','','','" onclick="
			document.QueryCorrAgencies.action=\''.$MODURL.'Lib/a04_COAG_rp.php\';
			subform(\'QueryCorrAgencies\',\'COAG_Results\');'); ?></td>
          </tr>
        </table>